package com.itheima.service.db.impl;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.crypto.SecureUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.domain.db.User;
import com.itheima.domain.db.UserInfo;
import com.itheima.domain.vo.PageBeanVo;
import com.itheima.mapper.UserInfoMapper;
import com.itheima.mapper.UserMapper;
import com.itheima.service.db.UserInfoService;
import com.itheima.service.db.UserService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService //加入到dubbo容器
public class UserInfoServiceImpl implements UserInfoService {


    @Autowired
    private UserInfoMapper userInfoMapper;
    @Override
    public void save(UserInfo userInfo) {
        userInfoMapper.insert(userInfo); //保存基本信息
    }

    @Override
    public void update(UserInfo userInfo) {
        userInfoMapper.updateById(userInfo);
    }

    @Override
    public UserInfo findByUserId(Long userId) {
        return userInfoMapper.selectById(userId);
    }

    @Override
    public PageBeanVo findByPage(Integer pageNum, Integer pageSize) {
        IPage page=  new Page(pageNum , pageSize);
        page = userInfoMapper.selectPage(page , null);
        return new PageBeanVo( pageNum , pageSize , page.getTotal() ,page.getRecords());
    }
}
